<x-layout>

  <!---->
  <div class="m-wrap g-ld invite-box">
    <div class="m-box">

      <div class="m-c wow fadeInUp">
        <div class="invite-logo">
          <img src="./img1/logo.png" alt="">
        </div>
        <div class="invite-mgf">
          <img src="./img1/invite-mgf.png" alt="">
        </div>

        <div class="invite-content">
          <input type="text" name="" id="i-addr" value="" readonly placeholder="xxxxxx">
          <button class="invite-icon-btn" data-clipboard-target="#i-addr"></button>
        </div>

        <div class="invite-title">
          <h3>我的邀请</h3>
        </div>

        <div class="invite-level">
          <div class="f-box">
            <div class="item">我的级别</div>
            <div class="item tc" id="i-level">无</div>
          </div>
          <div class="f-box">
            <div class="item">链接算力</div>
            <div class="item tc" id="i-link">0</div>
          </div>
          <div class="f-box">
            <div class="item">小区算力</div>
            <div class="item tc" id="i-area">0</div>
          </div>
        </div>

        <div class="invite-list">
          <h3>邀请列表</h3>
          <div class="invite-list-data" id="box">
            <div class="f-box">
              <div class="item">地址</div>
              <div class="item">小区业绩</div>
              <div class="item">团队算力</div>
            </div>

            <!-- <div class="f-box">
              <div class="item light">skkkss</div>
              <div class="item light">198822.11</div>
              <div class="item light">887277.99</div>
            </div> -->
          </div>
        </div>

      </div>
    </div>
  </div>


</x-layout>
<!--partner-->
<script src="https://cdn.jsdelivr.net/npm/clipboard@2.0.8/dist/clipboard.min.js"></script>

<script>
  var page = 1;

  function fetchNext(token, page) {
    //获取邀请列表
    axios.post(mgRoute.inviteList, {
      "current": page || 1,
      "size": 10
    }, {
      headers: {
        token: token
      }
    }).then((r) => {
      var d = r.data
      if (d.status == 200) {
        j = d.data
        items = j.list
        if (items.length > 0) {
          page++;

          var line = '';
          var len = items.length;
          for (i = 0; i < len; i++) {
            line += ' <div class="f-box"><div class="item light">' +
            parseStringToStar(items[i].identityCard) + '</div><div class="item light">' +
              items[i].minPerformance + '</div><div class="item light">' +
              items[i].teamPerformance + '</div></div>  '
          }

          if (line) {
            $("#box").append(line);
          }
        }

      } else {
        alert("请求失败")
      }
    }).catch((e) => {
      dlog(e)
    })

  }

  var clipboard = new ClipboardJS('.invite-icon-btn');
  clipboard.on('success', function(e) {
    alert("copied")
  });

  // alert(clipboard.isSupported())

  $(function() {

    token = mgToken()

    //获取邀请信息
    axios.post(mgRoute.invite, {}, {
      headers: {
        token: token
      }
    }).then((r) => {
      var d = r.data
      if (d.status == 200) {
        j = d.data
        $("#i-addr").val(j.address)
        $("#i-level").text(j.level)
        $("#i-link").text(j.linkComputingPower || 0)
        $("#i-area").text(j.minPerformance || 0)
      } else {
        alert("请求失败")
      }
    }).catch((e) => {
      dlog(e)
    })


    fetchNext(token, page);

  })
</script>